<?php /* @var $news News */ ?>
<?php include_component('tree'
                    , 'path'
                    , array('path' => 'news'
                        , 'label' => 'NEWS')); ?>
<br/>
<div class="text"> 
<?php if( has_any_role_id(array(MyConstants::ROLE_ADMIN, MyConstants::ROLE_MODERATOR))): ?>
    <?php echo link_to(image_tag('add.png'
                                , array('title' => __('add')
                                    , 'alt' => __('add')))
                    , 'news/create')?>&nbsp;
    <?php echo link_to(__('add'), 'news/create'); ?><br />
<?php endif; ?>
<h2><?php echo Tree::getNameForPathByLabel('NEWS', 'news'); ?></h2>
<div class="center_text">
<?php foreach( $pager->getResults() as $news ):?>
    <div class="news_item"">
        <?php echo seo_link_to($news->getName()
                            , 'news'
                            , 'view'
                            , $news->getId()
                            , array('style' => 'float:left;')); ?>&nbsp;&nbsp;&nbsp;
        <?php if( $sf_user->isAuthenticated() ): ?>
            <?php echo link_to(
                            image_tag(
                                'pencil.png'
                                , array(
                                    'alt' => 'edit'
                                )
                            )
                            , 'news/edit?id=' . $news->getId()); ?>
        <?php endif; ?>
    </div>
    
    <div style="clear: both; padding-bottom: 10px;"></div>
<?php endforeach; ?>

<?php if ($pager->haveToPaginate()): ?>
	<div class="paging">
		<div class="paging_link">
			<?php echo link_to(
					'&laquo;'
					, 'news/showall?page='.$pager->getFirstPage()
				) ?>
		</div>
		<div class="paging_link">
			 <?php echo link_to(
					'&lsaquo;'
					, 'news/showall?page='.$pager->getPreviousPage()
				) ?>
		</div>
			<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
			<?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'news/showall?page='.$page) . '</div>' ?>
			<?php if ($page != $pager->getCurrentMaxLink()): ?>
			<?php endif; ?>
			<?php endforeach; ?>
		<div class="paging_link">
			<?php echo link_to(
						'&rsaquo;'
						, 'news/showall?page='.$pager->getNextPage()
					) ?>
		</div>
		<div class="paging_link">
			<?php echo link_to(
						'&raquo;'
						, 'news/showall?page='.$pager->getLastPage()
					) ?>
		</div>
	</div>
<?php endif ?>

</div>
</div>
<div class="dashed_line">
</div>
<br/>